<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 3] 3.11 Summary</TITLE>
<META NAME="author" CONTENT="David Flanagan">
<META NAME="date" CONTENT="Thu Jul 31 15:50:05 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java in a Nutshell">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java in a Nutshell" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch03_10.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 3<br>Classes and Objects in Java</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch04_01.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JNUT2-CH-3-SECT-11">3.11 Summary</A></h2>

<P CLASS=para>
This has been a long and detailed chapter. The following
list summarizes the most important points to remember.
This summary is not intended to simplify the complex
material we've covered, but it may allow you to test your
comprehension of the material now, and may help jog your
memory later:

<P>
<UL CLASS=itemizedlist>
<li CLASS=listitem>A class is a collection of data and methods
that operate on that data.

<P>
<li CLASS=listitem>An object is a particular instance of a class.

<P>
<li CLASS=listitem>Object members (fields and methods) are accessed with a
dot between the object name and the member name.

<P>
<li CLASS=listitem>Instance (non-static) variables occur in each instance of a
class.

<P>
<li CLASS=listitem>Class (static) variables are associated with the class.
There is one copy of a class variable regardless of the
number of instances of a class.

<P>
<li CLASS=listitem>Instance (non-static) methods of a class are passed an
implicit <tt CLASS=literal>this</tt> argument that identifies the object
being operated on.

<P>
<li CLASS=listitem>Class (static) methods are not passed a <tt CLASS=literal>this</tt>
argument and therefore do not have a current instance of the
class that can be used to implicitly refer to instance
variables or invoke instance methods.

<P>
<li CLASS=listitem>Objects are created with the <tt CLASS=literal>new</tt> keyword, which
invokes a class constructor method with a list of arguments.

<P>
<li CLASS=listitem>Objects are not explicitly freed or destroyed in any way.
The Java garbage collector automatically reclaims objects
that are no longer being used.

<P>
<li CLASS=listitem>If the first line of a constructor method does not invoke
another constructor with a <tt CLASS=literal>this()</tt> call, or a
superclass constructor with a <tt CLASS=literal>super()</tt> call,
Java automatically inserts a call to the superclass
constructor that takes no arguments.  This enforces
"constructor chaining."

<P>
<li CLASS=listitem>If a class does not define a constructor, Java provides a
default constructor.  

<P>
<li CLASS=listitem>A class may inherit the non-<tt CLASS=literal>private</tt> methods and
variables of another class by "subclassing"--i.e., by
declaring that class in its <tt CLASS=literal>extends</tt> clause.

<P>
<li CLASS=listitem><tt CLASS=literal>java.lang.Object</tt> is the default superclass for a
class.  It is the root of the Java class hierarchy and has no
superclass itself.  All Java classes inherit the methods
defined by <tt CLASS=literal>Object</tt>.

<P>
<li CLASS=listitem>Method overloading is the practice of defining multiple
methods which have the same name but have different argument lists.

<P>
<li CLASS=listitem>Method overriding occurs when a class redefines a method
inherited from its superclass.  

<P>
<li CLASS=listitem>Dynamic method lookup ensures that the correct method is
invoked for an object, even when the object is an instance
of a class that has overridden the method.

<P>
<li CLASS=listitem><tt CLASS=literal>static</tt>, <tt CLASS=literal>private</tt>, and <tt CLASS=literal>final</tt> methods
cannot be overridden and are not subject to dynamic method
lookup.  This allows compiler optimizations such as
inlining.

<P>
<li CLASS=listitem>From a subclass, you can explicitly invoke an overridden
method of a superclass with the <tt CLASS=literal>super</tt> keyword.

<P>
<li CLASS=listitem>You can explicitly refer to a shadowed variable with the
<tt CLASS=literal>super</tt> keyword.

<P>
<li CLASS=listitem>Data and methods may be hidden or encapsulated within a
class by specifying the <tt CLASS=literal>private</tt>
or <tt CLASS=literal>protected</tt> visibility modifiers.
Members declared <tt CLASS=literal>public</tt> are visible everywhere.
Members with no visibility modifiers are visible only within
the package.

<P>
<li CLASS=listitem>An abstract method has no method body (i.e., no implementation).

<P>
<li CLASS=listitem>An abstract class contains abstract methods.  The methods
must be implemented in a subclass before the subclass can be
instantiated.

<P>
<li CLASS=listitem>An interface is a collection of abstract methods and
constants (<tt CLASS=literal>static</tt> <tt CLASS=literal>final</tt> variables).
Declaring an interface creates a new data type.

<P>
<li CLASS=listitem>A class implements an interface by declaring the interface
in its <tt CLASS=literal>implements</tt> clause and by providing a method
body for each of the abstract methods in the interface.

<P>
</UL>
</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch03_10.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch04_01.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>C++ Features Not Found in Java</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>What's New in Java 1.1</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
